#include "stdafx.h"
#include "MathFuncsDll.h"
#include <stdexcept>

using namespace std;

/*
1. create dll project win32->win32 console -> in "application type" choose "dll"
2. add the head file whose name is "MathFuncsDll.h" and "MathFuncs.cpp"
3. in "MathFuncsDll.h", add 
#ifdef MATHFUNCSDLL_EXPORTS
#define MATHFUNCSDLL_API __declspec(dllexport) 
#else
#define MATHFUNCSDLL_API __declspec(dllimport) 
#endif
and 
namespace xx
{
class define
}
4. in the .cpp file, make the functions to work.
*/

// This class is exported from the MathFuncsDll.dll

namespace MathFuncs
{
    double MyMathFuncs::Add(double a, double b)
    {
        return a + b;
    }

    double MyMathFuncs::Subtract(double a, double b)
    {
        return a - b;
    }

    double MyMathFuncs::Multiply(double a, double b)
    {
        return a * b;
    }

    double MyMathFuncs::Divide(double a, double b)
    {
        if (b == 0)
        {
            throw invalid_argument("b cannot be zero!");
        }

        return a / b;
    }
}